using System;
using System.Collections;
using System.Web.UI;
using System.Web.UI.WebControls;
using Curriculum.Services;


namespace ConcursoCV.UI.Clases.ManejadoresControles
{
	/// <summary>
	/// Summary description for ManejadorDropDownList.
	/// </summary>
	public class ManejadorDropDownList : ManejadorControles
	{
		public ManejadorDropDownList()
		{
		}
		public override void Cargar(WebControl ctrl, object value)
		{
			if(value != null)
				((DropDownList)ctrl).SelectedValue = (string) value;
		}
		public override void Inicializar(WebControl ctrl, object value)
		{
			DropDownList dropDownList = ((DropDownList)ctrl);
			char separator=':';
			string[] valor = ((string)value).Split(separator);   
			string idAntecedente = valor[0];
			string idAtributo = valor[1];
			VersionMetadatosService svc = new VersionMetadatosService();
			IList listaValores = svc.GetListaValores(idAntecedente,idAtributo);
			dropDownList.DataTextField = "Valor";
			dropDownList.DataValueField = "Id";
			dropDownList.DataSource = listaValores;
			dropDownList.DataBind();
		}
		public override string GetValor(WebControl ctrl)
		{
			return ((DropDownList)ctrl).SelectedValue.ToString();
		}
	}
}
